﻿using PetaPoco;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace Cxuu.Models
{
    [TableName("cxuu_article_cate")]
    [PrimaryKey("Id", AutoIncrement = true)]
    public class ArticleCate
    {
        public int Id { get; set; }

        public int Pid { get; set; }

        public string Name { get; set; }

        public int Type { get; set; }

        public string ObjectId1 { get; set; }
        public string Ico { get; set; }
        public string ObjectId2 { get; set; }

        public int Sort { get; set; }

        public int Num { get; set; }

    }

    public class EditArticleCate
    {
        [Display(Name = "上级类别")]
        public int Pid { get; set; }
        [Display(Name = "类别名称")]
        public string Name { get; set; }
        [Display(Name = "类别类型")]
        public int Type { get; set; }
        [Display(Name = "对象标识")]
        public string ObjectId1 { get; set; }
        [Display(Name = "对象标识2")]
        public string ObjectId2 { get; set; }
        [Display(Name = "类别图标")]
        public string Ico { get; set; }
        [RegularExpression(RegxPatterns.Number, ErrorMessage = "{0}必须为数字")]
        [Display(Name = "排序")]
        public int Sort { get; set; } = 0;
        [Display(Name = "显示条数")]
        public int Num { get; set; } = 15;
    }


    public class ViewArticleCate
    {
        public int Id { get; set; }

        public int Pid { get; set; }

        public string Title { get; set; }
        public int Type { get; set; }

        public string ObjectId1 { get; set; }
        /// <summary>
        /// 栏目图标
        /// </summary>
        public string Ico { get; set; }
        /// <summary>
        /// 对象标识2
        /// </summary>
        public string ObjectId2 { get; set; }
        public int Sort { get; set; }

        public int Num { get; set; }

        public int Depth { get; set; }
        /// <summary>
        /// 节点展开
        /// </summary>
        public string Spread { get; set; }
        /// <summary>
        /// 节点是否为禁用状态。默认 false
        /// </summary>
        public string Disabled { get; set; }

        public int ChildrenCount { get; set; }

        public bool HaveChild { get; set; }
        public bool Open { get; set; }
        public List<ViewArticleCate> Children { set; get; } = new();


    }
}